/*
 * $Id: LoggingClient.java 23 2002-09-29 13:59:30Z bpruessmann $
 * 
 * Copyright (c) 2001 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.p4eclipse.core.api;

import java.io.PrintStream;
import java.util.Iterator;

import net.sourceforge.p4eclipse.core.PerforceException;
import net.sourceforge.p4eclipse.core.syncinfo.FolderSyncInfo;
import net.sourceforge.p4eclipse.core.syncinfo.ResourceSyncInfo;

/**
  * @version	$Revision: 23 $
  * @author		<a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  */
public class LoggingClient extends Client
{
	private PrintStream infoPrintStream;
	private PrintStream errorPrintStream;	
	
	
	public void setInfoPrintStream(PrintStream printStream)
	{
		this.infoPrintStream = printStream;
	}

	public void setErrorPrintStream(PrintStream printStream)
	{
		this.errorPrintStream = printStream;
	}

	/** @see IClient#run(String[], IPerforceCommand) */
	public void run(String[] arguments, IPerforceCommand command)
	{
		if (infoPrintStream != null && !command.isHidingFromConsole())
		{
			StringBuffer buffer = new StringBuffer("-> Executing p4 " + command.getCommand());
			
			for (int i = 0, length = arguments.length; i < length; i++)
				buffer.append(" ").append(arguments[i]); //$NON-NLS-1$
				
			infoPrintStream.println(buffer.toString());
		}
		
		super.run(arguments, command);
	}
}

